import { Message } from '@arco-design/web-vue'
import { Ref, VNode } from 'vue'

export interface HeaderCellStyle {
  backgroundColor?: string
  color: string
}

export interface TableConfig {
  dataList: Array<any>
  stripe: boolean
  border: boolean
  size: string
  headerCellStyle: HeaderCellStyle
  height: string | number
  tableLoading: boolean
}

export interface SelectOptionItem {
  label: string
  value: any
}
export interface TableSearchItem {
  key: string
  label: string
  value: Ref<any>
  placeholder?: string
  associatedOption?: string
  onChange?: (value: any, associationItem: string) => void
  span?: number
}
export interface FormItem extends TableSearchItem {
  required?: boolean
  validator?: (value?: FormItem, message?: typeof Message) => boolean
  hidden?: boolean
  type?: string
  maxLength?: number
  rows?: number
  disabled?: Ref<boolean>
  optionItems?: Array<SelectOptionItem>
  path?: string
  reset?: (formItem?: FormItem) => void
  render?: (formItem: FormItem) => VNode
  isClear?: false
}

export interface FilterTableItem extends TableSearchItem {
  reset?: (formItem?: FilterTableItem) => void
  keyWidth?: number | string
  width?: number | string
  type: string
  isMultiple?: boolean
  keyItems?: Array<any>
  attrs?: { [propName: string]: any }
  optionItems?: Array<any>
  optionField?: { [propName: string]: any }
  disabledDate?: any
  isClear?: boolean
  isShowTag?: false
  undeletable?: boolean //禁止移除查询条件（用于必传参数）
  min?: number //最小值（用于区间筛选）
  max?: number //最大值（用于区间筛选）
  searchType?: string //精确或模糊
}

export interface LikeSearchModel {
  conditionItems: Array<TableSearchItem> | null
  extraParams?: (() => Record<string, any>) | Record<string, any>
}

export interface TablePropsType {
  title: string
  key: string
  sortIndex: number
  checked: boolean
}
export interface FilterKeywordType {
  label: string
  value: string | number
}
export interface ExportDataItem {
  exportApi: string
  fieldList: Array<any>
  tabName?: string
  supportTemplate?: boolean
  templateType?: string
  excelName?: string
}
export interface ExportInfo {
  title: string //dialog标题
  type: 'batch' | 'single' // 多表格导出
  exportApi?: string //导出API
  fieldList?: Array<any> //导出字段
  supportAll?: boolean //是否支持全部导出（为false时会判断是否勾选）
  tabName?: string //多表格导出时切换的tabname
  supportTemplate?: boolean //是否需要导出模板
  templateType?: string //导出模板的code，会根据这个code对应模板列表
  excelName?: string //导出文件名
  exportDatas?: Array<ExportDataItem> //多文件导出时导出信息放列表
}

// export type ModalDialogType = InstanceType<typeof ModalDialog>

export type ModalDialogType = InstanceType<typeof import('../components/common/ModalDialog.vue').default>

// export type DataFormType = InstanceType<typeof import('../components/common/DataForm').default>

export type TableHeaderType = InstanceType<typeof import('../components/common/TableHeader.vue').default>

export type TableFooterType = InstanceType<typeof import('../components/common/TableFooter.vue').default>
